<?php
require_once('parameters-hosting.php');
require_once('pdo.apprenant.php');
require_once('pdo.label.php');

class EVLDAOFactory {
	private static $elvDaoFactory;
	private $pdoHelper;
	private $apprenantPdo;
	private $labelPdo;

	private function __construct()
    {
        global $PARAM_url;
        global $PARAM_user;
        global $PARAM_pass;

		$this->pdoHelper = new PDO($PARAM_url, $PARAM_user, $PARAM_pass);
        $this->pdoHelper->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    	//echo('EVLDAOFactory: PDO object connected'.'<br/>');
    }

	public static function getInstance() {
		if (!isset(self::$vocDaoFactory)) {
			self::$elvDaoFactory = new EVLDAOFactory();
		}
		return self::$elvDaoFactory;
	}

 	public function getApprenant() {
		if (!isset($this->apprenantPdo)) {
			$this->apprenantPdo = new Apprenant($this->pdoHelper);
		}
		return $this->apprenantPdo;
	}

 	public function getLabel() {
		if (!isset($this->labelPdo)) {
			$this->labelPdo = new Label($this->pdoHelper);
		}
		return $this->labelPdo;
	}
}
?>
